cb048f4108b53dd811803abaa0b613e86b33d607,plugins/network-elements/stratosphere-ssp/src/org/apache/cloudstack/network/element/SspClient.java,SspClient,createTenantPort,#String#,212

Before Change


        req.attachmentType = "NoAttachment";

        PostMethod method = postMethod;
        method.setPath("/ssp.v1/tenant-ports");
        StringRequestEntity entity = null;
        try {
            entity = new StringRequestEntity(new Gson().toJson(req), "application/json", "UTF-8");
        } catch (UnsupportedEncodingException e) {
            s_logger.error("failed creating http request body", e);
            return null;
        }
        method.setRequestEntity(entity);

        String response = executeMethod(method);
        if (response != null && method.getStatusCode() == HttpStatus.SC_CREATED) {
            return new Gson().fromJson(response, TenantPort.class);
        }
        return null;

After Change


        req.networkUuid = tenantNetworkUuid;
        req.attachmentType = "NoAttachment";

        HttpPost method = new HttpPost();
        method.setEntity(new StringEntity(new Gson().toJson(req), ContentType.APPLICATION_JSON));
        HttpResponse res = executeMethod(method, "/ssp.v1/tenant-ports");

        if (res == null || res.getStatusLine().getStatusCode() != HttpStatus.SC_CREATED) {
            return null;
        }
        try {
            return new Gson().fromJson(new InputStreamReader(res.getEntity().getContent()),
                    TenantPort.class);
        } catch (JsonSyntaxException e) {
            s_logger.error("reading response body failed", e);
        } catch (JsonIOException e) {
            s_logger.error("reading response body failed", e);
        } catch (IllegalStateException e) {
            s_logger.error("reading response body failed", e);
        } catch (IOException e) {
            s_logger.error("reading response body failed", e);
        }
        return null;
    }